public class J103101 {
    public static int peakIndexInMountainArray(int[] arr) {
        int left = 0;
        int right = arr.length - 1;
        while (left <= right) {
            int mid = left + (right - left) / 2;
            if (arr[mid + 1] > arr[mid]) {
                left = mid + 1;
            } else if (arr [mid - 1] > arr[mid]) {
                right = mid - 1;
            } else {
                return mid;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        System.out.println(peakIndexInMountainArray(new int[]{1,3,29,30,34,35,42,60,64,73,91,94,91,85,80,75,71,63,54,53,42,27,24,21,14,11,10,9}));
    }
}
